if(!divObjAlreadyExists) {
	/*
		buildCss():  set up the css class to position/format the links
	*/
	function buildCss() {
		var styleElement = document.createElement("style");
		styleElement.type = "text/css";
		styleElement.innerHTML=".bcjShow{position:absolute;left:10px;top:27px;z-index:-1;border-style:solid;border-width:1xp;border-color:#80AC1D;color:white;z-index:100;background:rgb(255,255,255);background:rgba(255,255,255,1);padding:10px;}.bcjHide{display:none;}";
		document.getElementsByTagName("head")[0].appendChild(styleElement);
	} 

	/*
		appendDiv():  build the container div to hold the links
	*/
	function appendDiv(pv_divObj,pv_newDivName) {
		var ta1 = document.createElement('div');
		ta1.setAttribute("class","bcjShow");
		ta1.setAttribute("id",pv_newDivName);
		pv_divObj.appendChild(ta1);
	}

	/*
		appendLinks():  append individual links
	*/
	function appendLinks(pv_divObj,pv_company,pv_uName,pv_scVersion,pv_pwd) {
		var anchorTag = document.createElement('a');
		anchorTag.setAttribute('onclick', 'setValues("'+pv_company+'","'+pv_uName+'","'+pv_scVersion+'","'+pv_pwd+'");');
		anchorTag.innerHTML=pv_company;
		pv_divObj.appendChild(anchorTag);
		pv_divObj.appendChild(document.createElement('br'));
	}

	function appendCloseLink(pv_divObj,pv_linkText) {
		var closeLink = document.createElement('a');
		closeLink.setAttribute('id','closeLink');
		closeLink.style.textAlign="right";
		closeLink.setAttribute('onclick','document.getElementById("linksDiv").setAttribute("class","bcjHide");document.getElementById("username_input_field").focus();');
		closeLink.innerHTML=pv_linkText;
		pv_divObj.appendChild(closeLink);
	}
		
	function appendExternalLink(pv_divObj,pv_linkText,pv_linkHref,pv_linkId,pv_linkTarget) {
		var externalLink = document.createElement('a');
		externalLink.setAttribute('id',pv_linkId);
		externalLink.setAttribute('href',pv_linkHref);
		externalLink.setAttribute('target',(pv_linkHref)?pv_linkTarget:'');
		externalLink.innerHTML=pv_linkText;
		pv_divObj.appendChild(externalLink);
		pv_divObj.appendChild(document.createElement('br'));
	}
	
}

//get/build the div objects
var divObj=document.getElementById("linksDiv");
if(!divObj) {
	buildCss();
	var mainDiv=document.getElementById("middle_content");
	appendDiv(mainDiv,"linksDiv");
	var divObj=document.getElementById("linksDiv");
} else {
	var divObjAlreadyExists=true;
	divObj.setAttribute("class","bcjShow"); //show div
}

if(!divObjAlreadyExists) {
	//append the setValues js function that will update text box values and set focus on password field 
	var appendScript=document.createElement('script');
	appendScript.setAttribute('type','text/javascript');
	appendScript.innerHTML='function setValues(pv_company,pv_uName,pv_scVersion,pv_pwd){document.getElementById("company_input_field").value=pv_company;document.getElementById("username_input_field").value=pv_uName;OWL("CustomSelect",{element: "version_select",name: "version",selectedValue: pv_scVersion,selectedText: "Version "+pv_scVersion});(pv_pwd) ? document.getElementById("password_input_field").value=pv_pwd : document.getElementById("password_input_field").value="";document.getElementById("password_input_field").focus();document.getElementById("linksDiv").setAttribute("class","bcjHide");}';
	mainDiv.appendChild(appendScript);

	//build the links
	appendLinks(divObj,'Example 1','username1','15','');
	appendLinks(divObj,'Another Example','username2','14','');
	appendLinks(divObj,'Example Three','username3','15','password');
	appendExternalLink(divObj,'External Link','http://www.bcj19.com/','external-link-id','_blank');
	appendCloseLink(divObj,'[ X ]'); //add link to close/hide linksDiv
}